// 用户相关的接口请求函数

import type { Patient } from '@/types/user'
import type { User, CodeType, UserInfo } from '@/types/user.d'
import { request } from '@/utils/request'

// 手机号密码登录
export const loginByPassword = (mobile: string, password: string) =>
  request<User>('login/password', 'POST', { mobile, password })

// 获取验证码
export const sendMobileCode = (mobile: string, type: CodeType) =>
  request('/code', 'GET', { mobile, type })

// 验证码登录
export const loginByCode = (mobile: string, code: string) =>
  request<User>('/login', 'POST', { mobile, code })

// 用户信息
export const getUserInfo = () => request<UserInfo>('patient/myUser', 'GET', {})

// 问诊-查询患者列表信息
export const gePatientList = () =>
  request<Patient[]>('patient/mylist', 'GET', {})

// 添加患者、
export const addPatient = (patient: Patient) =>
  request('/patient/add', 'POST', patient)

// 编计患者
export const editPatient = (patient: Patient) =>
  request('/patient/update', 'PUT', patient)

// 删除患者
export const delPatient = (id: string) =>
  request(`patient/del/${id}`, 'DELETE', {})
